﻿using AccountFlow.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml.Serialization;

namespace AccountFlow.Controllers
{

    public class BookController : Controller
    {

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Chapter(string id)
        {
            ViewBag.ChapterName = id;
            return View();
        }

        [HttpPost]
        public ActionResult Save(BookModel viewModel)
        {
            XmlSerializer srz = new XmlSerializer(viewModel.GetType());
            using (FileStream fs = System.IO.File.OpenWrite(@"c:\temp\book.xml"))
            {
                srz.Serialize(fs, viewModel);
            }
            return Json(viewModel);
        }
       
    }
}
